<?php
#Created by Michel Gomes Ank
#E-mail: michel@lafanet.com.br
#MSN: mitheus@bol.com.br
#ICQ: 530377777

############################################# OPENNING CLASS FORM #############################################

class form {
	var $html = "";

	#Function: <form...>
	function form_start($name,$action,$method,$add='') {
		
		//$form .= "<form name=\"".$name."\" action=\"".$action."\" method=\"".$method."\" ".$add.">\n";
		$this->html = $this->form_start_echo($name,$action,$method,$add); 
		return true;
	}
	function form_start_echo($name,$action,$method,$add='') {
		$form = "<form name=\"".$name."\" action=\"".$action."\" method=\"".$method."\" ".$add.">\n";
		return $form;
	}

	#Function: <input text>
	function form_text($name_txt,$name,$length,$value='',$inside_table=false,$add='',$dps='') {
		//$temp = "\t<span>".$name_txt.": </span> <input type=\"text\" name=\"".$name."\" size=\"".$length."\" value=\"".$value."\" ".$add." /> ".$dps."<br />\n";
		$td='';
		$_td='';
		$tdl='';
		If ($inside_table) { 
			$td = '<td align="right">';
			$_td='</td>';
			$tdl = '<td align="left">';
		}
		$temp = "\t<span>".$td."<b>".$name_txt.":</b>".$_td. 
				"</span> "
				.$tdl."<input type=\"text\" name=\"".$name.
				"\" size=\"".$length."\" value=\"".$value."\" ".$add." /> ".$_td." ".$dps."<br />\n";
		$this->html .= $temp ;
		return $temp;
	}
	#Function: <input password>
	function form_password($name_pwd,$name,$length,$value='',$inside_table=false ,$add='',$dps='') {
		$td='';
		$_td='';
		$tdl='';		
		If ($inside_table) {
			$td = '<td align="right">';
			$_td='</td>';
			$tdl = '<td align="left">';
		}
		
		//$temp = "\t<span>".$name_txt.": </span> <input type=\"text\" name=\"".$name."\" size=\"".$length."\" value=\"".$value."\" ".$add." /> ".$dps."<br />\n";
		$temp = "\t<span> ".$td." <b>".$name_pwd.": </b>".$_td. "</span>"
			.$tdl."<input type=\"password\" name=\"".$name."\" size=\"".$length."\" value=\"".$value."\" ".$add." /> "
			.$_td." ".$dps."<br />\n";
		$this->html .= $temp ;
		return $temp;
	}

	#Function: <input password>
	function abrir_tabla($width='80%', $css_id='id_tabla_transparente') {
		//
		$temp = "\n<table id=".$css_id." width=".$width." >";
		$this->html .= $temp ;
		return $temp;
	}
	#Function: <input password>
	function cerrar_tabla() {
		//
		$temp = "\n</table>";
		$this->html .= $temp ;
		return $temp;
	}
	
	#Function: <html puro>
	function html_puro($htmlpuro) {
		//
		$temp = "\n".$htmlpuro."\n";
		$this->html .= $temp ;
		return $temp;
	}
	
	#Function: <selects>
	function form_select($name_txt,$name,$size,$opt_name,$opt_value,$selected='',$add='') {
		$select = "\t<span>".$name_txt.": </span>";
		$select .= "<select name=\"".$name."\" ".$add.">\n";
		$opt_name = explode(",",$opt_name);
		$opt_value = explode(",",$opt_value);
		$qts = count($opt_name);
		for($i=0;$i<$qts;$i++) {
			if($opt_value[$i] == $selected) {
				$select .= "\t\t<option selected value=\"".$opt_value[$i]."\">".$opt_name[$i]."</option>\n";
			}else{
				$select .= "\t\t<option value=\"".$opt_value[$i]."\">".$opt_name[$i]."</option>\n";
			}
		}
		$select .= "\t</select><br />\n";
		$this->html .= $select ;
		return $select;
	}
	#Function: <input checkbox...>
	function form_checkbox($name_txt,$name,$checked='',$value='1',$add='') {
		if($checked) $checked = "checked";
		$salida = "\t<span>".$name_txt.": </span>".$this->form_hidden($name)."<input type=\"checkbox\" name=\"".$name."\" ".$checked." value=\"".$value."\" class=\"checkbox\" ".$add." /><br />\n";
		$this->html .= $salida ;
		return $salida ;
	}
	#Function: <textarea...>
	function form_textarea($name_txt,$name,$rows,$cols,$value='',$add='') {
		$temp = "\t<span>".$name_txt.":<br /><textarea name=\"".$name."\" rows=\"".$rows."\" cols=\"".$cols."\">".$value."</textarea></span><br />\n";
		$this->html .= $temp ;
		return $temp;
	}
	#Function: <input file>
	function form_file($name_txt,$name,$add='',$dps='') {
		$temp = "\t<span>".$name_txt."</span><input type=\"file\" name=\"".$name."\" ".$add." /> ".$dps."<br />";
		$this->html .= $temp ;
		return $temp;
	}
	#Function: <input hidden...>
	function form_hidden($name,$value='',$add='') {
		$temp = "\t<input type=\"hidden\" name=\"".$name."\" value=\"".$value."\" ".$add." />";
		$this->html .= $temp;
		return $temp;
	}
	#Function: Submit/Reset
	function form_go($submit,$reset='') {
		$salida = "\n\t<span><br />";
		$salida .= "<input type=\"submit\" name=\"submit\" value=\"".$submit."\" class=\"submit\" />";
		if($reset) {
			$salida .= "&nbsp;&nbsp;&nbsp;<input type=\"reset\" name=\"reset\" value=\"".$reset."\" />";
		}
		$salida .= "</span>\n";
		$this->html .= $salida ;
		return $salida;
	}
	#Closing the form
	function form_end() {
		$this->html .= $this->form_end_echo();
		return true;
	}
	#Closing the form
	function form_end_echo() {
		return "</form>\n";
	}

}
############################################# CLOSING CLASS FORM #############################################

?>
